Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] Inter-batch-parellelism #8700

Closed
wants to merge 28 commits into from
Closed

[Feat] Inter-batch-parellelism #8700

wants to merge 28 commits into from

Conversation

tchaton
Copy link
Contributor

@tchaton tchaton commented Aug 3, 2021

What does this PR do?

Fixes #8316

Does your PR introduce any breaking changes? If yes, please list them.

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

Did you have fun?

Make sure you had fun coding 🙃

@pep8speaks
Copy link

pep8speaks commented Aug 3, 2021

Hello @tchaton! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 1950:19: E203 whitespace before ':'

Comment last updated at 2021-08-10 13:31:14 UTC

@codecov
Copy link

codecov bot commented Aug 3, 2021

Codecov Report

Merging #8700 (53eb4d7) into master (f1cc6e3) will decrease coverage by 49%.
The diff coverage is 32%.

@@           Coverage Diff            @@
##           master   #8700     +/-   ##
========================================
- Coverage      93%     43%    -49%     
========================================
  Files         169     170      +1     
  Lines       14068   14146     +78     
========================================
- Hits        13038    6138   -6900     
- Misses       1030    8008   +6978     

return


class LightningFetcher:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

n00b question: certain classes are prefixed with Lightning while others aren't.
Components with name:

  • LightningModule, LightningDataModule, LightningLoggerBase
  • without: Trainer, Callbacks, Logger, Profiler

utilities like this don't contain logic specific to the rest of the framework, so I wonder if we could call this just Prefetcher?

it can also help users feel like they're not needing to learn lightning-specific things

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would propose DataFetcher.


for _ in range(self.num_prefetch_batches + 1):
if not done:
with torch.cuda.stream(cuda_stream):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this validate somewhere that torch.cuda is available?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self,
dataloader,
batch_to_device: Callable,
profiler: "pl.profiler.base.BaseProfiler",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could the profiler be optional? the lightning trainer would always set this, but this becomes a handy utility for users outside the project too (it might even draw them into the project)

Comment on lines +34 to +35
This class is used to perform ``pre-fetching`` for the ``train`` dataloader
and apply inter batch parallelism if enabled.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could/should be used for evaluation too to still overlap the forward with host to device transfer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, added in fault tolerant training PRs :)

@tchaton tchaton closed this Aug 22, 2021
@Borda Borda deleted the inter_batch_parallism branch March 29, 2022 05:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a flavor of training_step that allows for expressing inter-batch parallelism
4 participants